import java.util.Arrays;
import java.util.Comparator;

public class Test {
    public static void main(String[] args) {
        Student1[] studnets = new Student1[4];
        studnets[0] = new Student1("张三", 169.5,23);
        studnets[1] = new Student1("张四", 163.8,26);
        studnets[2] = new Student1("张五", 163.8,26);
        studnets[3] = new Student1("张六", 167.5,24);

//        Arrays.sort(studnets, new Comparator<Student1>() {
//            @Override
//            public int compare(Student1 o1, Student1 o2) {
//                return Double.compare(o2.getHeight(), o1.getHeight()); //降序
//            }
//        });

        // 使用Lambda表达式简化
        Arrays.sort(studnets, (o1, o2) -> Double.compare(o2.getHeight(), o1.getHeight()));

        System.out.println(Arrays.toString(studnets));
    }
}
